﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sharpCmd.Controls.Viewers
{
    /// <summary>
    /// ViewerForm - a dialog for viewing files
    /// </summary>
    internal partial class ViewerForm : Form
    {
        //TODO complete viewer
        /// <summary>
        /// Creates new instance of ViewerForm
        /// </summary>
        public ViewerForm()
        {
            InitializeComponent();
            //TODO load viewer default settings
            viewerType = ViewerType.Text;
        }

        public string SelectedFile { get; set; }
        private ViewerType viewerType;
        private ViewerControl viewerControl;
        
        /// <summary>
        /// Changes the viewer type
        /// </summary>
        public ViewerType ViewerType
        {
            get { return viewerType; }
            set
            {
                viewerType = value;
                ShowViewer();
            }
        }

        public void ShowViewer()
        {
            //load viewer
            viewerControl = ViewerControl.Get(viewerType);
            viewerControl.SelectedFile = SelectedFile;
            viewerControl.Initialize();
            this.panelContent.Controls.Clear();
            this.panelContent.Controls.Add(viewerControl);
            viewerControl.Display();
        }

        private void wrapTextToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void ViewerForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape)
                Close();
        }
    }
}